﻿(function ($) {
    $.fn.serializeJson = function () {
        var serializeObj = {};
        $(this.serializeArray()).each(function () {
            serializeObj[this.name] = this.value;
        });
        return serializeObj;
    };
})(jQuery);
(function ($) {
    $.getUrlParam = function (name) {
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
        var r = window.location.search.substr(1).match(reg);
        if (r != null) return unescape(r[2]); return null;
    }
})(jQuery);
(function ($) {
    $.exitApp = function () {
        navigator.notification.confirm(
              '您确定要退出吗？',    // 消息
              function (button) {
                  if (button == "确定") {
                      navigator.app.exitApp();
                  }
              },       // 使用所按下按钮的索引进行回调
              '退出',     // 标题
              '确定,取消'  // 按钮标签
         );
    }
})(jQuery);
function nano(template, data) {
    return template.replace(/\{([\w\.]*)\}/g, function (str, key) {
        var v = data[key];
        //var keys = key.split("."), v = data[keys.shift()];
        //for (var i = 0, l = keys.length; i < l; i++) v = v[keys[i]];
        return (typeof v !== "undefined" && v !== null) ? v : "";
    });
}
(function ($) {
    var messageManager = Proxy.GetInstance("MO.BusinessServer.MessageManager");

    function MessageFun() {
        messageManager.Invoke("GetMessage", [], function (result) {
            if (result != null) {
                cordova.exec(function (args) {
                },
                function (args) {
                },
                'Notice', '',
                [{ title: result.Title, content: result.Content }]);

                if (window.confirm(result.Content)) {
                    if (result.Type == "form") {
                        location.href = result.Url;
                    }
                    //alert("确定");
                    return true;
                } else {
                    //alert("取消");
                    return false;
                }
            }
        });
        setTimeout(MessageFun, 10000);
    }
    setTimeout(MessageFun, 10000);
})(jQuery);

